﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;

using System.Net.Mail;

public partial class agent_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = null;

        con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        con.Open();
        SqlCommand cmd = new SqlCommand("SELECT * FROM agent_add where email='" + TextBox1.Text + "' and pass='" + TextBox2.Text + "'", con);

        SqlDataReader dr = cmd.ExecuteReader();
        // Response.Write(@"<script language='javascript'>alert('loop 1')</script>");

        if (dr.Read())
        {
            // Response.Write(@"<script language='javascript'>alert('inside')</script>");
            if (TextBox1.Text.Equals(dr[13].ToString()) && TextBox2.Text.Equals(dr[14].ToString()))
            {
                Session["email"] = TextBox1.Text;
                string type = dr[15].ToString();

                if (type == "Agent")
                {
                    Session["email"] = TextBox1.Text;
                    //Response.Redirect("recruiter_verify1.aspx");
                    Response.Redirect("agent/dashboard_agent.aspx");
                    con.Close();
                }

            }
        }
        else
        {
            Response.Write(@"<script language='javascript'>alert('Wrong password')</script>");
        }
    }
}